package 多线程.回顾复习;

public class Task implements Runnable {
    private final String message;

    // 构造函数，接受参数
    public Task(String message) {
        this.message = message;
    }

    @Override
    public void run() {
        // 执行任务
        System.out.println("Task message: " + message);
    }
}

class Main {
    public static void main(String[] args) {
        // 创建 Runnable 实例，传入参数
        Runnable task = new Task("Hello, world!");

        // 创建 Thread 并传入 Runnable 实例
        Thread thread = new Thread(task);


        // 启动线程
        thread.start();
    }
}

